﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Net;
using System.Web;


namespace WpfClient.Classes
{
    public class SendEmail : IDisposable
    {
        private MailMessage message = new MailMessage();

        public string SMTPAdress { get; set; }

        public string Password { get; set; }

        public string UserName { get; set; }

        public MailMessage Message { get; set; }

        public SendEmail()
        {

        }

        public void Send()
        {
            SmtpClient client = new SmtpClient(SMTPAdress);// { Port = 587 /*465;//gmail 587//mail & yandex 25or 2525*/, EnableSsl = false, DeliveryMethod = SmtpDeliveryMethod.Network };//new SmtpClient("smtp.mail.ru", 25);       

            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.Port = 587;
            //client.UseDefaultCredentials = false;

            client.Credentials = new NetworkCredential(UserName,Password);

            client.Send(Message);

            client.Dispose();
        }

        public void Dispose()
        {
            message.Dispose();
        }
    }
}
